<template>
  <div>
    <el-empty description="您当前还没有粉丝哦~" v-if="myFansList.length < 1">
    </el-empty>
    <el-row type="flex" justify="center" class="fans_item" v-for="f in myFansList">
      <el-col :span="22">
        <div class="avatar_box">
          <img :src="imgUrl + f.avatar" alt="">
          <div class="nick_name_desc">
            <span class="fans_nickname" @click="showOtherInfo(f.id)">{{f.nickname}}</span>
            <p>{{f.description}}</p>
          </div>
<!--          <div class="follow_him">-->
<!--            <span @click="fo">+关  注</span>-->
<!--          </div>-->
        </div>
      </el-col>
    </el-row>
    <div class="block" style="margin-left: 35%;margin-top: 30px;margin-bottom: 30px" >
      <el-pagination
          background
          :hide-on-single-page="true"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-size="pageSize"
          layout="prev, pager, next, jumper"
          :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
export default {
  name: "authorFans",
  props:['authorId'],
  data(){
    return{
      myFansList:[],
      currentPage:1,
      total:5,
      pageSize:5,
      imgUrl:this.$Myurl.userImageUrl
    }
  },
  methods:{
    // getUserNames(arr) {
    //   if (!arr) return;
    //   let userNameArr = new Array();
    //   for (let i = 0; i < arr.length; i++) {
    //     userNameArr.push(arr[i].nickname);
    //   }
    //   return userNameArr.join(",");
    // },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
      this.getOtherArticles()
    },
    showOtherInfo(uid){
      console.log(uid+'--------->'+this.userId)
      if(uid == this.userId){
        this.$router.push({
          path:'/personalCenter',
        })
        return;
      }
      this.$router.push({
        path:'/otherInfo',
        query:{
          authorId:uid,
        }
      })
    },
    getOtherArticlesFans(){
      let url = 'user/getFansByUserId'
      this.$axios.get(url,{
        params:{
          now:this.currentPage,
          size:this.pageSize,
          userId:this.authorId,
        }

      }).then(res=>{
        if (res.data.code == 200){
          this.myFansList = res.data.data.list;
          this.currentPage = res.data.data.pageNum;
          this.total = res.data.data.total;
          this.pageSize = res.data.data.pageSize;
          console.log(res)
        }
      })

    },

  },
  created() {
    this.getOtherArticlesFans()
  }
}
</script>

<style scoped>
.author_article_body h3{
  padding: 8px 20px;
  margin: 0;
  border-bottom: 1px solid lightgray;
}

.fans_item{
  width: 90%;
  margin-left: 5%;
  margin-top: 30px;

}
.fans_nickname:hover {
  cursor: pointer;
  color: #5bc65b;
}

.avatar_box img {
  height: 60px;
  width: 60px;
  line-height: 60px;
  border-radius: 50%;
  display: inline-block;
  float: left;
}
.nick_name_desc{
  width: 360px;
  height: 60px;
  float: left;
}
.nick_name_desc span {
  font-size: 20px;
  font-weight: bolder;
  margin-left: 40px;
}
.nick_name_desc p {
  font-size: 12px;
  margin:12px 0 0 40px;
}
.follow_him {
  width: 80px;
  height: 10px;
  box-sizing: border-box;;
  line-height: 60px;
  float: left;
  margin-left: 30px;
}
.follow_him span{
  width: 80px;
  height: 46px;
  line-height: 36px;
  border: 1px solid lightgray;
  font-size: 16px;
  padding-top: 6px;
  border-radius: 8px;
  font-weight: bolder;
  text-align: center;
  display: inline-block;
}
.follow_him span:hover{
  background-color: #f1f0f0;
}

</style>